package com.itheima.app.config;

import com.itheima.app.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 需要将拦截器配置 springboot容器
 */
@Configuration //配置类
public class WebConfig implements WebMvcConfigurer { //实现mvc的接口

    @Autowired //注入拦截器
    private TokenInterceptor tokenInterceptor;
    //注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/user/login","/user/loginVerification");
    }
}
